package com.zs.zcerp.entrance.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zs.zcerp.entrance.entity.Syorg;
import com.zs.zcerp.entrance.mapper.SyorgMapper;
import com.zs.zcerp.entrance.service.ISyorgService;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.List;

@DS("oracle")
@Service
public class SyorgServiceImpl extends ServiceImpl<SyorgMapper, Syorg> implements ISyorgService {

    @Override
    public List<Syorg> listSyorgs() {
        return baseMapper.selectList(new QueryWrapper<Syorg>().orderByAsc("ORG_ID"));
    }

    @Override
    public List<Syorg> listSyorgsLately() {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, -1);
        return baseMapper.selectList(new QueryWrapper<Syorg>().gt("LAST_DATE",c.getTime()).orderByAsc("ORG_ID"));
    }

    @Override
    public Syorg getSyorg(Integer orgId) {
        return baseMapper.selectOne(new QueryWrapper<Syorg>().eq("ORG_ID", orgId));
    }

    @Override
    public List<Syorg> listNotSyorgs() {
        return baseMapper.selectList(new QueryWrapper<Syorg>().ne("ORG_ID", 1200).orderByAsc("ORG_ID"));
    }
}
